<!--历史考勤-->
<template>
  <div>
    <div class="hearder-search">
      <div class="breadcrumb-container">
        <el-input v-model="searchForm.name" placeholder="姓名" @keyup.enter.native="searchBtn" size="small"
                  class="w-140 mr-10"></el-input>
        <el-button type="primary" size="small" @click="searchFn('search')" class="ml-10"><i class="el-icon-search"></i>搜索</el-button>
        <el-button size="small" @click="searchFn('refresh')"><i class="el-icon-refresh"></i>重置刷新</el-button>
      </div>
    </div>
    <!--本体列表，数据 -->
    <div class="table-body">
      <div class="table-body-box">
        <el-table
            ref="multipleTable"
            :data="arryList"
            :border="tableoption.tableBorder"
            tooltip-effect="dark">
          <el-table-column
              label="学生姓名"
              align="center"
              prop="name"
              :key="1">
            <template slot-scope="scope">
              {{scope.row.recruit.job?scope.row.recruit.job.name:'-'}}
            </template>
          </el-table-column>
          <el-table-column
              label="学生班级"
              align="center"
              prop="name"
              :key="2">
          </el-table-column>
          <el-table-column
              label="出勤情况"
              align="center"
              prop="use_time"
              :key="4">
            <template slot-scope="scope">
              <viewerModle type="1" :imgSrc="scope.row.pic"></viewerModle>
            </template>
          </el-table-column>
        </el-table>
      </div>
    </div>
    <!--工具条 分页-->
    <el-col :span="24" class="toolbar">
      <el-pagination
          background
          :page-size="page.pagesize"
          :current-page="page.pageindex"
          layout="total, prev, pager, next"
          :total="page.total"
          @current-change="handleSizeChange"></el-pagination>
    </el-col>
    <!--    简历详情 resumeType edit 可编辑 show 只展示-->
    <!--     :resumeType="activeName=='first'?'edit':'show'"-->
  </div>
</template>

<script>
import {pagination, tableoption, yeartime} from '@/utils/util.js'


export default {
  components: {
  },
  data() {
    return {
      tableList: [{name: '全部', id: 0}],
      tableoption: tableoption,
      page: {
        pageindex: pagination.pageIndex,
        pagesize: pagination.pageSize,
        total: pagination.total
      },
      first_id: '',
      arryList: [], // 数据列表
      // 搜索
      searchWord: '',
      searchCatId: 0,
      // 弹窗
      dialogVisible: false,
      editIndex: null,
      foodOption: '',
      dialogType: null,
      activeName: 'first',
      activeNamechange: 'first', // 切换导航
      resumeVisible: false,
      resumeId: 0,
      searchForm: {
        job_id: '',
        name: ''
      },
      jobList: [],
      numberList: [0, 0]
    }
  },
  created() {
    this.JobFn()
    this.InitFn()
  },
  methods: {
    // 初始化
    async InitFn() {
      // <!--        resumeType 1 查看简历 2 待处理的简历 3 待面试简历 4 考核中的应聘者 5 一录用应聘者-->
      // p 	整型 	必填 	1 	- 	页码
      // rercuit_sn 	字符串 	必填 	1 	- 	招聘发布编号
      // title 	字符串 	必填 	1 	- 	招聘名称
      // name 	字符串 	必填 	1 	- 	面试人
      // mobile_phone 	字符串 	必填 	1 	- 	面试人电话
      // status 	字符串 	必填 	1 	- 	0待审核1通过2驳回
      // recruit_id
      // statuss 0 简历待审核 1 待面试 2 简历驳回不符合 3 面试淘汰 4 考核中 5 录用 6 考核不通过 7 离职中 8 离职通过 9 离职驳回
      // 0 简历待处理 1 历史审核记录 2 面试待处理 3 面试历史 4 录用待处理 5 录用历史
      let option = {
        p: this.page.pageindex,
        status: 0,
        type: this.activeName === 'first' ? 0 : 1
      };
      console.log('option:', option)
      let data = await this.$fetch(this.api.recruit.vitae.index, option);
      console.log('data:', data)
      this.arryList = data.list.data
      this.page.total = data.list.total
      this.numberList = this.getJson(data.number)
    },
    getJson(option) {
      return JSON.parse(JSON.stringify(option))
    },
    cateListFn() {
      this.$fetch(this.api.cate_list, {
        p: 1
      }).then((response) => {
        if (response.code === 0) {
          for (let i in response.list.data) {
            this.tableList.push(response.list.data[i])
          }
        } else {
        }
      }).catch((err) => {
        console.log(err)
      })
    },
    // 分页
    handleSizeChange(val) {
      this.page.pageindex = val
      this.InitFn()
    },
    handleSelectionChange(val) {
      console.log(val) // 所有选中值
      this.handleSelection = val
    },
    // 编辑
    handleEdit(index, option) {
      this.editIndex = index
      this.foodOption = this.arryList[index]
      this.dialogType = option
      this.dialogVisible = true
    },
    // 搜索
    searchBtn() {
      this.page.pageindex = 1
      this.InitFn()
    },
    addFood(option) {
      this.dialogType = option
      this.dialogVisible = true
    },
    // 刷新页面
    refreshFn() {
      this.page.pageindex = 1
      this.searchCatId = ''
      this.searchCatId = 0
      this.InitFn()
    },
    handleDetel(index) {
      let this_ = this
      this.$confirm('此操作将永久删除 ' + this.arryList[index].name + ' 菜品, 是否继续?', '提示', {
        confirmButtonText: '确定',
        cancelButtonText: '取消',
        closeOnClickModal: false,
        type: 'warning'
      }).then(() => {
        this_.deletFn(index)
      }).catch(() => {
      })
    },
    deletFn(index) {
      this.$post(this.api.food_delete, {
        id: this.arryList[index].id
      }).then((response) => {
        if (response.code === 0) {
          this.$message({
            type: 'success',
            message: '删除成功!'
          })
          this.InitFn()
        } else {
        }
      }).catch((err) => {
        console.log(err)
      })
    },
    handleClick(tab, event) {
      if (this.activeName !== this.activeNamechange) {
        this.activeNamechange = this.activeName;
        this.page.pageindex = 1
        this.arryList = []
        this.InitFn()
      }
    },
    showDetail(id) {
      this.resumeId = id
      this.resumeVisible = true
    },
    // 获取岗位信息
    async JobFn() {
      let data = await this.$fetch(this.api.recruit.job.index, {p: 1});
      this.jobList = data.list.data;
    },
    searchFn(option) {
      if (option === 'refresh') {
        this.searchForm.name = ''
        this.searchForm.job_id = ''
      }
      this.page.pageindex = 1;
      this.InitFn()
    },
    detelFn (id, index) {
      let self_ = this;
      this.$confirm('此简历将永久删除，确认删除此简历？', '提示', {
        confirmButtonText: '确定',
        cancelButtonText: '取消',
        type: 'warning'
      }).then(() => {
        self_.$post(this.api.recruit.vitae.delete, {
          id: id
        }).then((response) => {
          if (response.code === 0) {
            this.InitFn()
            this.$message.success(response.msg)
          } else {
            this.$message.error(response.msg)
          }
        }).catch((err) => {
          console.log(err)
        })
      }).catch(() => {

      })
    }
  },
  mounted() {
  }
}
</script>
<style>
</style>
